/**
 * 
 */
package authentication;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Checks whether user is authenticated or not.
 * 
 * @author Stefan
 * 
 */
public class AuthenticatedServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7544123679661375158L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {

		req.getSession(true).setAttribute("isAuthenticated", "true");

		if (req.getSession().getAttribute("isAuthenticated") != null) {
			resp.getWriter().write(
					req.getSession().getAttribute("isAuthenticated").toString());
		} else {
			resp.getWriter().write("false");
		}
		resp.getWriter().flush();
	}
}
